//
//  Database.h
//  cliqset
//
//  Created by David Hinson on 2/16/09.
//  Copyright 2009 Sumner Systems Management, Inc.. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "sqlite3.h"
#import "Contact.h"

@interface Database : NSObject {

}

-(void)addFavorite:(NSString*)uid cid:(NSString*)cid;
- (void)createEditableCopyOfDatabaseIfNeeded;
-(BOOL)databaseNeedsUpdate;
-(NSString*)getDatabasePath;
-(int)isContactAFavorite:(NSString*)uid cid:(NSString*)cid;
-(void)loadContactsFromDatabase:(NSString *)uid;
-(void)loadEventsFromDatabase:(NSString *)uid;
-(void)loadFavorites:(NSString*)uid;
-(void)loadCountriesFromDatabase:(int)index code:(NSMutableString**)code name:(NSMutableString**)name;
-(int)countCountriesFromDatabase;
-(int)countContactsFromDatabase;
-(int)countEventsFromDatabase;

#pragma mark ---- puts ----
-(void)putEmailAddress:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag content:(NSString*)content flag:(BOOL)flag;
-(void)putPhone:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag content:(NSString*)content flag:(BOOL)flag;
-(void)putIM:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag content:(NSString*)content flag:(BOOL)flag;
-(void)putURL:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag content:(NSString*)content;
-(void)putAddress:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag street:(NSString*)street locality:(NSString*)locality region:(NSString*)region postalCode:(NSString*)postalCode country:(NSString*)country;
-(void)putContact:(Contact*)contact;

#pragma mark ---- removes ----
-(void)removeAddress:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag;
-(void)removeContact:(NSString*)uid cid:(NSString*)cid;
-(void)removeEmailAddress:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag;
-(void)removeIM:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag;
-(void)removePhone:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag;
-(void)removeURL:(NSString*)uid cid:(NSString*)cid tag:(NSString *)tag;
-(void)removeFavorite:(NSString*)uid cid:(NSString*)cid;

-(void)resetTimestamp;
-(void)saveContactsToDatabase;
-(void)saveEventsToDatabase;
-(NSString*)getLatestEventDateFromDatabase;
-(NSString*)getLatestContactDateFromDatabase;

@end
